package com.cjg.netCode;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.*;

public class udpChar {
    public static void main(String[] args) throws Exception {
        DatagramSocket ds = new DatagramSocket();

        while (true){
            BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));
            String s = bufferedReader.readLine();
            byte[] bytes = s.getBytes();
            int length = bytes.length;

            InetSocketAddress socket = new InetSocketAddress("127.0.0.1", 7777);
            DatagramPacket datagramPacket = new DatagramPacket(bytes,0,length,socket);
            ds.send(datagramPacket);
            if (s.equals("bye")){
                break;
            }

        }
        ds.close();

    }
}
